package com.syni.mdd.sjb.marketing.basemarket.service.commom.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.syni.mdd.sjb.common.component.mybatis.common.entity.DxshAppUserInfo;
import com.syni.mdd.sjb.common.component.mybatis.common.mapper.DxshAppUserInfoMapper;
import com.syni.mdd.sjb.marketing.basemarket.service.commom.DxshAppUserInfoService;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 电享生活商户APP 个人资料信息 服务实现类
 * </p>
 *
 * @author lcc
 * @since 2020-04-27
 */
@Service
public class DxshAppUserInfoServiceImpl extends ServiceImpl<DxshAppUserInfoMapper, DxshAppUserInfo> implements DxshAppUserInfoService {
    @Autowired
    DxshAppUserInfoMapper dxshAppUserInfoMapper;

    @Override
    public String getUnionIdByUserId(Integer userId) {
        QueryWrapper queryWrapper = new QueryWrapper();
        queryWrapper.eq(DxshAppUserInfo.USER_ID,userId);
        List<DxshAppUserInfo> dxshAppUserInfos = dxshAppUserInfoMapper.selectList(queryWrapper);
        if(CollectionUtils.isNotEmpty(dxshAppUserInfos)){
            return dxshAppUserInfos.get(0).getUnionId();
        }
        return null;
    }
}
